package com.luban.hs.controller;


import com.luban.hs.mode.UserDto;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: hs
 * @Description:
 * @Date: Create in 20:14 2019/2/2
 */
@Component("/user")
public class BeanController implements Controller {

    /**
     * Process the request and return a ModelAndView object which the DispatcherServlet
     * will render. A {@code null} return value is not an error: it indicates that
     * this object completed request processing itself and that there is therefore no
     * ModelAndView to render.
     *
     * @param request  current HTTP request
     * @param response current HTTP response
     * @return a ModelAndView to render, or {@code null} if handled directly
     * @throws Exception in case of errors
     */
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        System.out.println("beanController");
        ModelAndView mv = new ModelAndView();
        mv.setViewName("userView.html");
        UserDto userDto = new UserDto();
        userDto.setName("huangShun");
        mv.addObject(userDto);
        //具体怎么用，需要去了解一下，估计跟templates有关系
        return mv;
    }
}
